package com.ydj.app.utils;

import com.ydj.framework.redis.ExtRedisTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 算号器
 */
@Component
public class AutoIncrementUtils {
    @Autowired
    ExtRedisTemplate redisTemplate;

    public synchronized String get(String key) {
        Long counter = redisTemplate.opsForValue().increment(key);
        return String.format("%s%04d", key, counter);

    }
}
